{% extends "base.html" %}
{% load multifor %}

{% block title %}Confirmar pedido{% endblock %}

{% block body_navegacao %}
<table class="table table-striped">
    <thead> 
        <tr>
            <th>Item</th>
            <th>Preço</th>
            <th>Quantidade</th>
            <th>Preço total</th>
        </tr>
    </thead>
    <tbody>
        {% for pizza in pedido.pizzapedida_set.all %}
        <tr>
            <td>{{ pizza }}</td>
            <td>{{ pizza.preco }}</td>
            <td>{{ pizza.quantidade }}</td>
            <td>{{ pizza.preco_total }}</td>
        </tr>
        {% endfor %}
        {% for item in pedido.itempedido_set.all %}
        <tr>
            <td>{{ item.item }}</td>
            <td>{{ item.item.preco }}</td>
            <td>{{ item.quantidade }}</td>
            <td>{{ item.preco_total }}</td>
        </tr>
        {% endfor %}
        <tr>
            <td><strong>Total (sem taxa de entrega)</strong></td>
            <td></td><td></td>
            <td><strong>{{ pedido.valor_total }}</strong></td>
        </tr>
    </tbody>
</table>
<form method="post" action="{% url confirmar_pedido %}">
    {% csrf_token %}
    <p>{{ form.errors }}</p>
    <p>{{ form.valor_pago.label }} {{ form.valor_pago }}</p>
    <table class="table table-striped">
        <thead> 
            <tr>
                <th>{{ form.endereco.label }}</th>
                <th></th>
                <th>Taxa de entrega</th>
            </tr>
        </thead>
        <tbody>
            {% for option in form.endereco; frete in fretes %}
            <tr>
                <td>{{ option.tag }}</td>
                <td>{{ option.choice_label }}</td>
                <td>{{ frete }}</th>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    <table class="table table-striped">
        <thead> 
            <tr>
                <th>{{ form.telefone.label }}</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for option in form.telefone %}
            <tr>
                <td>{{ option.tag }}</td>
                <td>{{ option.choice_label }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    <button type="submit" title="concluir">Confirmar</button>
</form>
<a href="{% url fazer_pedido %}">Corrigir pedido</a><br />
<a href="{% url cancelar_pedido %}">Cancelar pedido</a>
{% endblock %}
